package com.atguigu.day02;

import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import java.util.Arrays;
import java.util.List;

public class Flink01_Source_Collection {
    public static void main(String[] args) throws Exception {
        //1.获取流的执行环境
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        env.setParallelism(1);

        //TODO 2.从集合中获取数据
        List<Integer> list = Arrays.asList(1, 2, 3, 4);
//        DataStreamSource<Integer> streamSource = env.fromCollection(list).setParallelism(1);
        //可以设置多并行版本
//        env.fromParallelCollection()

        //TODO 从元素中获取数据
        DataStreamSource<Integer> streamSource1 = env.fromElements(1, 2, 3, 4);

        streamSource1.print();
//        streamSource.print();
        env.execute();
    }
}
